package study.bigdata.flink.job.mysql;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction;

@Slf4j
public class MySqlBinlogJob {

    @SneakyThrows
    public static void main(String[] args) {
        //
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // 并行
//        env.setParallelism(1);
        //检查点
//        env.enableCheckpointing(1000, CheckpointingMode.EXACTLY_ONCE);
//        CheckpointConfig checkpointConfig = env.getCheckpointConfig();
//        checkpointConfig.setMinPauseBetweenCheckpoints(500);
        //

        //======  ======
        env.addSource(new MySqlBinlogSourceFunction()) //source
                .addSink(new PrintSinkFunction())      //sink
                .uid("")
                .name("mysql_binlog");

        //====== 执行 ======
        env.execute("mysql_binlog");

    }
}
